package com.cndw.kungfu.model.message;

import java.util.List;

import com.cndw.kungfu.domain.Player;
import com.cndw.kungfu.model.Context;

/**
 * 群发任务线程
 * 
 * 
 * @author <a href="mailto:whz-work@163.com">汪洪州</a>
 * 
 * @since 1.0 Create on 2011-5-28
 */
public class GroupSendTask implements Runnable {

	private long sendPlayerId;
	private String title;
	private String content;
	private List<Long> receviers;

	public GroupSendTask(long sendPlayerId, List<Long> receviers, String title, String content) {
		this.sendPlayerId = sendPlayerId;
		this.title = title;
		this.content = content;
		this.receviers = receviers;
	}

	@Override
	public void run() {

		Player sendPlayer = Context.getPlayerServer().getByPlayerId(sendPlayerId);

		for (Long recevierId : receviers) {
			Player recevier = Context.getPlayerServer().getByPlayerId(recevierId);
			if (recevier == null) {
				continue;
			}
			Context.getMessageServer().sendMail(recevierId, recevier.getPlayerName(), sendPlayer.getPlayerId(), sendPlayer.getPlayerName(), title, content);
		}
	}
}
